﻿#include "progressservice.h"

#include <databasecenter.h>

ProgressService::ProgressService(QObject *parent) : QObject(parent)
{
    db = DatabaseCenter::getInstance()->getConnection();
}

ProgressService::~ProgressService()
{
    DatabaseCenter::getInstance()->releaseConnection(db);
}

bool ProgressService::getPageList(uint64_t &total, QList<Progress> &users, const uint64_t &page, const uint64_t &pageSize)
{
    ProgressDao objectDao(db);
    return (objectDao.getTotalByParam(total) && objectDao.getPageListByParam(users,page,pageSize));
}


bool ProgressService::getList(QList<Progress> &list)
{
    ProgressDao objectDao(db);
    return (objectDao.getList(list));
}

bool ProgressService::getOne(Progress &object)
{
    ProgressDao objectDao(db);
    return (objectDao.getOne(object));
}

bool ProgressService::saveOne(Progress &object)
{
    ProgressDao objectDao(db);
    return (objectDao.saveOne(object));
}

bool ProgressService::deleteOne(Progress &object)
{
    ProgressDao objectDao(db);
    return (objectDao.deleteOne(object));
}

QSqlDatabase ProgressService::getDb() const
{
    return db;
}
